home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Games / NetHack 3.1.3 / source / sys / share / dgn_lex.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-08-01  |  31.4 KB  |  1,146 lines  |  [TEXT/R*ch]

  1. /* A lexical scanner for NetHack generated by flex */
  2.  
  3. /* scanner skeleton version:
  4.  * flexhack.skel 3.1.3 (from .../flex/RCS/flex.skel,v 2.16 90/08/03 14:09:36)
  5.  */
  6. #define FLEXHACK_SCANNER
  7.  
  8. /* amount of stuff to slurp up with each read */
  9. #ifndef YY_READ_BUF_SIZE
  10. #define YY_READ_BUF_SIZE 8192
  11. #endif
  12.  
  13. /* returned upon end-of-file */
  14. #define YY_END_TOK 0
  15.  
  16. /* copy whatever the last rule matched to the standard output */
  17. #define ECHO (void)fwrite((genericptr_t)yytext, yyleng, 1, yyout)
  18.  
  19. /* gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
  20.  * is returned in "result".
  21.  */
  22. #define YY_INPUT(buf,result,max_size) \
  23.     if ((result = fread((genericptr_t)buf, 1, max_size, yyin)) <= 0 && \
  24.         !feof(yyin))  YY_FATAL_ERROR( "fread(yyin) in flex scanner failed" );
  25. #define YY_NULL 0
  26.  
  27. /* no semi-colon after return; correct usage is to write "yyterminate();" */
  28. #define yyterminate() return ( YY_NULL )
  29.  
  30. /* report a fatal error */
  31. #define YY_FATAL_ERROR(msg) \
  32.     do { \
  33.         (void) fputs( msg, stderr ); \
  34.         (void) putc( '\n', stderr ); \
  35.         exit( 1 ); \
  36.     } while ( 0 )
  37.  
  38. /* default yywrap function - always treat EOF as an EOF */
  39. #define yywrap() 1
  40.  
  41. /* enter a start condition.  This macro really ought to take a parameter,
  42.  * but we do it the disgusting crufty way forced on us by the ()-less
  43.  * definition of BEGIN
  44.  */
  45. #define BEGIN yy_start = 1 + 2 *
  46.  
  47. /* action number for EOF rule of a given start state */
  48. #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  49.  
  50. /* special action meaning "start processing a new file" */
  51. #define YY_NEW_FILE \
  52.     do { \
  53.         yy_init_buffer( yy_current_buffer, yyin ); \
  54.         yy_load_buffer_state(); \
  55.     } while ( 0 )
  56.  
  57. /* default declaration of generated scanner - a define so the user can
  58.  * easily add parameters
  59.  */
  60. #define YY_DECL int NDECL(yylex)
  61.  
  62. /* code executed at the end of each rule */
  63. #define YY_BREAK break;
  64.  
  65. #define YY_END_OF_BUFFER_CHAR 0
  66.  
  67. #ifndef YY_BUF_SIZE
  68. #define YY_BUF_SIZE (YY_READ_BUF_SIZE * 2) /* size of default input buffer */
  69. #endif
  70.  
  71. typedef struct yy_buffer_state *YY_BUFFER_STATE;
  72.  
  73. #define YY_CHAR char
  74. #define INITIAL 0
  75. /*    SCCS Id: @(#)dgn_lex.c    3.1    93/06/17    */
  76. /*    Copyright (c) 1989 by Jean-Christophe Collet */
  77. /*    Copyright (c) 1990 by M. Stephenson         */
  78. /* NetHack may be freely redistributed.  See license for details. */
  79.  
  80. #define DGN_COMP
  81.  
  82. #include "config.h"
  83. #include "dgn_comp.h"
  84. #include "dgn_file.h"
  85.  
  86. long *FDECL(alloc, (unsigned int));
  87. /*
  88.  * Most of these don't exist in flex, yywrap is macro and
  89.  * yyunput is properly declared in flex.skel.
  90.  */
  91. #if !defined(FLEX_SCANNER) && !defined(FLEXHACK_SCANNER)
  92. int FDECL(yyback, (int *, int));
  93. int NDECL(yylook);
  94. int NDECL(yyinput);
  95. int NDECL(yywrap);
  96. int NDECL(yylex);
  97.     /* Traditional lexes let yyunput() and yyoutput() default to int;
  98.      * newer ones may declare them as void since they don't return
  99.      * values.  For even more fun, the lex supplied as part of the
  100.      * newer unbundled compiler for SunOS 4.x adds the void declarations
  101.      * (under __STDC__ or _cplusplus ifdefs -- otherwise they remain
  102.      * int) while the bundled lex and the one with the older unbundled
  103.      * compiler do not.  To detect this, we need help from outside --
  104.      * sys/unix/Makefile.utl.
  105.      */
  106. # if defined(NeXT) || defined(SVR4)
  107. #  define VOIDYYPUT
  108. # endif
  109. # if !defined(VOIDYYPUT)
  110. #  if defined(POSIX_TYPES) && !defined(BOS) && !defined(HISX) && !defined(_M_UNIX)
  111. #   define VOIDYYPUT
  112. #  endif
  113. # endif
  114. # if !defined(VOIDYYPUT) && defined(WEIRD_LEX)
  115. #  if defined(SUNOS4) && defined(__STDC__) && (WEIRD_LEX > 1) 
  116. #   define VOIDYYPUT
  117. #  endif
  118. # endif
  119. # ifdef VOIDYYPUT
  120. void FDECL(yyunput, (int));
  121. void FDECL(yyoutput, (int));
  122. # else
  123. int FDECL(yyunput, (int));
  124. int FDECL(yyoutput, (int));
  125. # endif
  126. #endif    /* !FLEX_SCANNER && !FLEXHACK_SCANNER */
  127.  
  128. void FDECL(init_yyin, (FILE *));
  129. void FDECL(init_yyout, (FILE *));
  130.  
  131. #ifdef MICRO
  132. #undef exit
  133. extern void FDECL(exit, (int));
  134. #endif
  135.  
  136. /* this doesn't always get put in dgn_comp.h
  137.  * (esp. when using older versions of bison)
  138.  */
  139.  
  140. extern YYSTYPE yylval;
  141.  
  142. int line_number = 1;
  143. /*
  144.  *    This is a hack required by Michael Hamel to get things
  145.  *    working on the Mac.
  146.  */
  147. #if defined(applec) && !defined(FLEX_SCANNER) && !defined(FLEXHACK_SCANNER)
  148. #undef input
  149. #undef unput
  150. #define unput(c) { yytchar = (c); if (yytchar == 10) yylineno--; *yysptr++ = yytchar; }                  
  151. # ifndef YYNEWLINE
  152. # define YYNEWLINE 10
  153. # endif
  154.  
  155. char
  156. input()        /* Under MPW \n is chr(13)! Compensate for this. */
  157. {
  158.     if (yysptr > yysbuf) return(*--yysptr);
  159.     else {
  160.         yytchar = getc(yyin);
  161.          if (yytchar == '\n') {
  162.             yylineno++;
  163.             return(YYNEWLINE);
  164.         }
  165.         if (yytchar == EOF) return(0);
  166.         else            return(yytchar);
  167.     }
  168. }
  169. #endif    /* applec && !FLEX_SCANNER && !FLEXHACK_SCANNER */
  170.  
  171.  
  172. /* done after the current pattern has been matched and before the
  173.  * corresponding action - sets up yytext
  174.  */
  175. #define YY_DO_BEFORE_ACTION \
  176.     yytext = yy_bp; \
  177.     yyleng = yy_cp - yy_bp; \
  178.     yy_hold_char = *yy_cp; \
  179.     *yy_cp = '\0'; \
  180.     yy_c_buf_p = yy_cp;
  181.  
  182. #define EOB_ACT_CONTINUE_SCAN 0
  183. #define EOB_ACT_END_OF_FILE 1
  184. #define EOB_ACT_LAST_MATCH 2
  185.  
  186. /* return all but the first 'n' matched characters back to the input stream */
  187. #define yyless(n) \
  188.     do { \
  189.         /* undo effects of setting up yytext */ \
  190.         *yy_cp = yy_hold_char; \
  191.         yy_c_buf_p = yy_cp = yy_bp + n; \
  192.         YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  193.     } while ( 0 )
  194.  
  195. #define unput(c) yyunput((int)c, yytext)
  196.  
  197.  
  198. struct yy_buffer_state {
  199.     FILE *yy_input_file;
  200.  
  201.     YY_CHAR *yy_ch_buf;        /* input buffer */
  202.     YY_CHAR *yy_buf_pos;    /* current position in input buffer */
  203.  
  204.     /* size of input buffer in bytes, not including room for EOB characters */
  205.     int yy_buf_size;
  206.  
  207.     /* number of characters read into yy_ch_buf, not including EOB characters */
  208.     int yy_n_chars;
  209.  
  210.     int yy_eof_status;        /* whether we've seen an EOF on this buffer */
  211. #define EOF_NOT_SEEN 0
  212.     /* "pending" happens when the EOF has been seen but there's still
  213.      * some text process
  214.      */
  215. #define EOF_PENDING 1
  216. #define EOF_DONE 2
  217. };
  218.  
  219. static YY_BUFFER_STATE yy_current_buffer;
  220.  
  221. /* we provide macros for accessing buffer states in case in the
  222.  * future we want to put the buffer states in a more general
  223.  * "scanner state"
  224.  */
  225. #define YY_CURRENT_BUFFER yy_current_buffer
  226.  
  227.  
  228. /* yy_hold_char holds the character lost when yytext is formed */
  229. static YY_CHAR yy_hold_char;
  230.  
  231. static int yy_n_chars;        /* number of characters read into yy_ch_buf */
  232.  
  233.  
  234. #ifndef YY_USER_ACTION
  235. #define YY_USER_ACTION
  236. #endif
  237.  
  238. #ifndef YY_USER_INIT
  239. #define YY_USER_INIT
  240. #endif
  241.  
  242. extern YY_CHAR *yytext;
  243. extern int yyleng;
  244. extern FILE *yyin, *yyout;
  245.  
  246. YY_CHAR *yytext;
  247. int yyleng;
  248.  
  249. FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
  250.  
  251. #define YY_END_OF_BUFFER 36
  252. typedef int yy_state_type;
  253. static const short int yy_accept[194] =
  254.     {   0,
  255.         0,    0,   36,   34,   33,   32,   34,   29,   34,   34,
  256.        34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
  257.        34,   34,   34,   34,   34,   34,   34,   34,   33,    0,
  258.        30,   29,    0,    0,    0,    0,    0,    0,    0,    0,
  259.         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  260.         0,    0,    0,    2,    0,   31,    0,    0,    0,    0,
  261.         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  262.         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  263.         0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  264.         3,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  265.  
  266.         0,   14,    0,    0,    0,    0,    0,    0,    4,    0,
  267.        25,    0,    0,    0,    0,    0,    0,    0,    0,    0,
  268.         6,    0,    0,    0,    5,    0,    0,   23,    0,    0,
  269.         0,    0,    0,    0,    0,    0,    0,    0,    0,   20,
  270.         0,    0,    0,    0,    8,    0,    0,    0,    0,    0,
  271.         0,    1,    0,    0,    0,    0,    0,   22,   15,    0,
  272.        21,    7,   19,    0,    0,    0,    0,    0,    0,   13,
  273.         0,    0,    0,   26,   16,    0,    0,   12,    0,    0,
  274.         0,   11,    9,    0,   17,   18,    0,   27,    0,   28,
  275.        24,   10,    0
  276.  
  277.     } ;
  278.  
  279. static const YY_CHAR yy_ec[128] =
  280.     {   0,
  281.         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
  282.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  283.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  284.         1,    2,    1,    4,    5,    1,    1,    1,    1,    1,
  285.         1,    1,    1,    1,    6,    1,    1,    6,    6,    6,
  286.         6,    6,    6,    6,    6,    6,    6,    1,    1,    1,
  287.         1,    1,    1,    1,    7,    8,    9,   10,   11,   12,
  288.        13,   14,   15,    1,    1,   16,   17,   18,   19,   20,
  289.         1,   21,   22,   23,   24,   25,    1,    1,   26,    1,
  290.         1,    1,    1,    1,   27,    1,   28,    1,   29,   30,
  291.  
  292.        31,   32,   33,   34,   35,    1,   36,   37,   38,   39,
  293.        40,   41,    1,   42,   43,   44,   45,    1,   46,    1,
  294.         1,   47,    1,    1,    1,    1,    1
  295.     } ;
  296.  
  297. static const YY_CHAR yy_meta[48] =
  298.     {   0,
  299.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  300.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  301.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  302.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  303.         1,    1,    1,    1,    1,    1,    1
  304.     } ;
  305.  
  306. static const short int yy_base[196] =
  307.     {   0,
  308.         0,  212,  216,  218,  213,  218,  210,  207,  196,  190,
  309.       196,   37,  191,  197,  186,  188,  171,  164,  172,  174,
  310.       173,   18,  160,  159,  154,  157,   11,  193,  193,  190,
  311.       218,  187,  177,  184,  183,  167,  170,  164,  161,  166,
  312.       174,  155,  136,  144,  134,  132,  133,   26,  135,  143,
  313.       147,  128,  145,  218,  169,  218,  158,  152,  154,  159,
  314.       154,  145,   44,  142,   47,  124,  124,  125,  129,  129,
  315.       115,   27,  121,  113,  111,  120,  115,  116,  134,  142,
  316.       132,  128,  137,  121,  130,  129,  125,  129,  131,   97,
  317.       218,  105,   94,  101,   95,   96,   94,   99,  105,  101,
  318.  
  319.        89,  218,   95,  112,  114,   51,  112,  107,  218,  110,
  320.       114,  111,  106,   96,   85,   76,   81,   82,   88,   69,
  321.       218,   81,   76,   75,  218,   78,   99,  218,   88,   97,
  322.        87,   88,   92,   93,   88,   91,   90,   71,   65,  218,
  323.        62,   60,   57,   56,  218,   59,   54,   74,   84,   65,
  324.        66,  218,   70,   65,   70,   60,   68,  218,  218,   52,
  325.       218,  218,  218,   46,   50,   57,   61,   67,   62,  218,
  326.        67,   64,   63,  218,  218,   42,   41,  218,   61,   53,
  327.        49,  218,  218,   50,  218,  218,   51,  218,   46,  218,
  328.       218,  218,  218,   61,   59
  329.  
  330.     } ;
  331.  
  332. static const short int yy_def[196] =
  333.     {   0,
  334.       193,    1,  193,  193,  193,  193,  194,  193,  193,  193,
  335.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  336.       193,  193,  193,  193,  193,  193,  193,  195,  193,  194,
  337.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  338.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  339.       193,  193,  193,  193,  195,  193,  193,  193,  193,  193,
  340.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  341.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  342.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  343.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  344.  
  345.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  346.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  347.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  348.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  349.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  350.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  351.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  352.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  353.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  354.       193,  193,    0,  193,  193
  355.  
  356.     } ;
  357.  
  358. static const short int yy_nxt[266] =
  359.     {   0,
  360.         4,    5,    6,    7,    4,    8,    9,   10,   11,   12,
  361.        13,    4,    4,    4,    4,   14,    4,    4,    4,   15,
  362.        16,    4,    4,    4,    4,    4,    4,    4,   17,   18,
  363.         4,    4,    4,   19,    4,    4,   20,   21,   22,    4,
  364.        23,   24,   25,   26,   27,    4,    4,   36,   47,   53,
  365.        85,   54,   72,   73,   86,   88,   96,   48,  129,   55,
  366.        37,   30,   89,  192,  191,  190,  130,  189,  188,  187,
  367.       186,   97,  185,  184,  183,  182,  181,  180,  179,  178,
  368.       177,  176,  175,  174,  173,  172,  171,  170,  169,  168,
  369.       167,  166,  165,  164,  163,  162,  161,  160,  159,  158,
  370.  
  371.       157,  156,  155,  154,  153,  152,  151,  150,  149,  148,
  372.       147,  146,  145,  144,  143,  142,  141,  140,  139,  138,
  373.       137,  136,  135,  134,  133,  132,  131,  128,  127,  126,
  374.       125,  124,  123,  122,  121,  120,  119,  118,  117,  116,
  375.       115,  114,  113,  112,  111,  110,  109,  108,  107,  106,
  376.       105,  104,  103,  102,  101,  100,   99,   98,   95,   94,
  377.        93,   92,   91,   90,   87,   84,   83,   82,   81,   80,
  378.        79,   56,   78,   77,   76,   75,   74,   71,   70,   69,
  379.        68,   67,   66,   65,   64,   63,   62,   61,   60,   59,
  380.        58,   57,   32,   31,   29,   56,   52,   51,   50,   49,
  381.  
  382.        46,   45,   44,   43,   42,   41,   40,   39,   38,   35,
  383.        34,   33,   32,   31,   29,  193,   28,    3,  193,  193,
  384.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  385.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  386.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  387.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  388.       193,  193,  193,  193,  193
  389.     } ;
  390.  
  391. static const short int yy_chk[266] =
  392.     {   0,
  393.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  394.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  395.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  396.         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
  397.         1,    1,    1,    1,    1,    1,    1,   12,   22,   27,
  398.        63,   27,   48,   48,   63,   65,   72,   22,  106,  195,
  399.        12,  194,   65,  189,  187,  184,  106,  181,  180,  179,
  400.       177,   72,  176,  173,  172,  171,  169,  168,  167,  166,
  401.       165,  164,  160,  157,  156,  155,  154,  153,  151,  150,
  402.       149,  148,  147,  146,  144,  143,  142,  141,  139,  138,
  403.  
  404.       137,  136,  135,  134,  133,  132,  131,  130,  129,  127,
  405.       126,  124,  123,  122,  120,  119,  118,  117,  116,  115,
  406.       114,  113,  112,  111,  110,  108,  107,  105,  104,  103,
  407.       101,  100,   99,   98,   97,   96,   95,   94,   93,   92,
  408.        90,   89,   88,   87,   86,   85,   84,   83,   82,   81,
  409.        80,   79,   78,   77,   76,   75,   74,   73,   71,   70,
  410.        69,   68,   67,   66,   64,   62,   61,   60,   59,   58,
  411.        57,   55,   53,   52,   51,   50,   49,   47,   46,   45,
  412.        44,   43,   42,   41,   40,   39,   38,   37,   36,   35,
  413.        34,   33,   32,   30,   29,   28,   26,   25,   24,   23,
  414.  
  415.        21,   20,   19,   18,   17,   16,   15,   14,   13,   11,
  416.        10,    9,    8,    7,    5,    3,    2,  193,  193,  193,
  417.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  418.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  419.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  420.       193,  193,  193,  193,  193,  193,  193,  193,  193,  193,
  421.       193,  193,  193,  193,  193
  422.     } ;
  423.  
  424. static yy_state_type yy_last_accepting_state;
  425. static YY_CHAR *yy_last_accepting_cpos;
  426.  
  427. /* the intent behind this definition is that it'll catch
  428.  * any uses of REJECT which flex missed
  429.  */
  430. #define REJECT reject_used_but_not_detected
  431. #define yymore() yymore_used_but_not_detected
  432. #define YY_MORE_ADJ 0
  433.  
  434. /* these variables are all declared out here so that section 3 code can
  435.  * manipulate them
  436.  */
  437. /* points to current character in buffer */
  438. static YY_CHAR *yy_c_buf_p = (YY_CHAR *) 0;
  439. static int yy_init = 1;        /* whether we need to initialize */
  440. static int yy_start = 0;    /* start state number */
  441.  
  442. /* flag which is used to allow yywrap()'s to do buffer switches
  443.  * instead of setting up a fresh yyin.  A bit of a hack ...
  444.  */
  445. static int yy_did_buffer_switch_on_eof;
  446.  
  447. static yy_state_type NDECL(yy_get_previous_state);
  448. static yy_state_type FDECL(yy_try_NUL_trans, (yy_state_type));
  449. static int NDECL(yy_get_next_buffer);
  450. #if 0        /* not needed for NetHack */
  451. static int NDECL(yyinput);
  452. static void FDECL(yyunput, (int,YY_CHAR *));
  453. #endif
  454. void FDECL(yyrestart, (FILE *));
  455. void FDECL(yy_switch_to_buffer, (YY_BUFFER_STATE));
  456. void NDECL(yy_load_buffer_state);
  457. YY_BUFFER_STATE FDECL(yy_create_buffer, (FILE *,int));
  458. void FDECL(yy_delete_buffer, (YY_BUFFER_STATE));
  459. void FDECL(yy_init_buffer, (YY_BUFFER_STATE,FILE *));
  460.  
  461. #define yy_new_buffer yy_create_buffer
  462.  
  463. YY_DECL
  464. {
  465.     register yy_state_type yy_current_state;
  466.     register YY_CHAR *yy_cp, *yy_bp;
  467.     register int yy_act;
  468.  
  469.  
  470.  
  471.     if ( yy_init )
  472.     {
  473.     YY_USER_INIT;
  474.  
  475.     if ( ! yy_start )
  476.         yy_start = 1;    /* first start state */
  477.  
  478.     if ( ! yyin )
  479.         yyin = stdin;
  480.  
  481.     if ( ! yyout )
  482.         yyout = stdout;
  483.  
  484.     if ( yy_current_buffer )
  485.         yy_init_buffer( yy_current_buffer, yyin );
  486.     else
  487.         yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
  488.  
  489.     yy_load_buffer_state();
  490.  
  491.     yy_init = 0;
  492.     }
  493.  
  494.     while ( 1 )        /* loops until end-of-file is reached */
  495.     {
  496.     yy_cp = yy_c_buf_p;
  497.  
  498.     /* support of yytext */
  499.     *yy_cp = yy_hold_char;
  500.  
  501.     /* yy_bp points to the position in yy_ch_buf of the start of the
  502.      * current run.
  503.      */
  504.     yy_bp = yy_cp;
  505.  
  506.     yy_current_state = yy_start;
  507.     if ( yy_bp[-1] == '\n' )
  508.         ++yy_current_state;
  509. yy_match:
  510.     do
  511.         {
  512.         register YY_CHAR yy_c = yy_ec[*yy_cp];
  513.         if ( yy_accept[yy_current_state] )
  514.         {
  515.         yy_last_accepting_state = yy_current_state;
  516.         yy_last_accepting_cpos = yy_cp;
  517.         }
  518.         while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  519.         {
  520.         yy_current_state = yy_def[yy_current_state];
  521.         if ( yy_current_state >= 194 )
  522.             yy_c = yy_meta[yy_c];
  523.         }
  524.         yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  525.         ++yy_cp;
  526.         }
  527.     while ( yy_current_state != 193 );
  528.     yy_cp = yy_last_accepting_cpos;
  529.     yy_current_state = yy_last_accepting_state;
  530.  
  531. yy_find_action:
  532.     yy_act = yy_accept[yy_current_state];
  533.  
  534.     YY_DO_BEFORE_ACTION;
  535.     YY_USER_ACTION;
  536.  
  537. do_action:    /* this label is used only to access EOF actions */
  538.  
  539.  
  540.     switch ( yy_act )
  541.         {
  542.         case 0: /* must backtrack */
  543.         /* undo the effects of YY_DO_BEFORE_ACTION */
  544.         *yy_cp = yy_hold_char;
  545.         yy_cp = yy_last_accepting_cpos;
  546.         yy_current_state = yy_last_accepting_state;
  547.         goto yy_find_action;
  548.  
  549. case 1:
  550. return(A_DUNGEON);
  551.     YY_BREAK
  552. case 2:
  553. { yylval.i=1; return(UP_OR_DOWN); }
  554.     YY_BREAK
  555. case 3:
  556. { yylval.i=0; return(UP_OR_DOWN); }
  557.     YY_BREAK
  558. case 4:
  559. return(ENTRY);
  560.     YY_BREAK
  561. case 5:
  562. return(STAIR);
  563.     YY_BREAK
  564. case 6:
  565. return(NO_UP);
  566.     YY_BREAK
  567. case 7:
  568. return(NO_DOWN);
  569.     YY_BREAK
  570. case 8:
  571. return(PORTAL);
  572.     YY_BREAK
  573. case 9:
  574. return(PROTOFILE);
  575.     YY_BREAK
  576. case 10:
  577. return(DESCRIPTION);
  578.     YY_BREAK
  579. case 11:
  580. return(LEVELDESC);
  581.     YY_BREAK
  582. case 12:
  583. return(ALIGNMENT);
  584.     YY_BREAK
  585. case 13:
  586. return(LEVALIGN);
  587.     YY_BREAK
  588. case 14:
  589. { yylval.i=TOWN ; return(DESCRIPTOR); }
  590.     YY_BREAK
  591. case 15:
  592. { yylval.i=HELLISH ; return(DESCRIPTOR); }
  593.     YY_BREAK
  594. case 16:
  595. { yylval.i=MAZELIKE ; return(DESCRIPTOR); }
  596.     YY_BREAK
  597. case 17:
  598. { yylval.i=ROGUELIKE ; return(DESCRIPTOR); }
  599.     YY_BREAK
  600. case 18:
  601. { yylval.i=D_ALIGN_NONE ; return(DESCRIPTOR); }
  602.     YY_BREAK
  603. case 19:
  604. { yylval.i=D_ALIGN_NONE ; return(DESCRIPTOR); }
  605.     YY_BREAK
  606. case 20:
  607. { yylval.i=D_ALIGN_LAWFUL ; return(DESCRIPTOR); }
  608.     YY_BREAK
  609. case 21:
  610. { yylval.i=D_ALIGN_NEUTRAL ; return(DESCRIPTOR); }
  611.     YY_BREAK
  612. case 22:
  613. { yylval.i=D_ALIGN_CHAOTIC ; return(DESCRIPTOR); }
  614.     YY_BREAK
  615. case 23:
  616. return(BRANCH);
  617.     YY_BREAK
  618. case 24:
  619. return(CHBRANCH);
  620.     YY_BREAK
  621. case 25:
  622. return(LEVEL);
  623.     YY_BREAK
  624. case 26:
  625. return(RNDLEVEL);
  626.     YY_BREAK
  627. case 27:
  628. return(CHLEVEL);
  629.     YY_BREAK
  630. case 28:
  631. return(RNDCHLEVEL);
  632.     YY_BREAK
  633. case 29:
  634. { yylval.i=atoi(yytext); return(INTEGER); }
  635.     YY_BREAK
  636. case 30:
  637. { yytext[yyleng-1] = 0; /* Discard the trailing \" */
  638.           yylval.str = (char *) alloc(strlen(yytext+1)+1);
  639.           strcpy(yylval.str, yytext+1); /* Discard the first \" */
  640.           return(STRING); }
  641.     YY_BREAK
  642. case 31:
  643. { line_number++; }
  644.     YY_BREAK
  645. case 32:
  646. { line_number++; }
  647.     YY_BREAK
  648. case 33:
  649. ;    /* skip trailing tabs & spaces */
  650.     YY_BREAK
  651. case 34:
  652. { return yytext[0]; }
  653.     YY_BREAK
  654. case 35:
  655. ECHO;
  656.     YY_BREAK
  657. case YY_STATE_EOF(INITIAL):
  658.     yyterminate();
  659.  
  660.         case YY_END_OF_BUFFER:
  661.         {
  662.         /* amount of text matched not including the EOB char */
  663.         int yy_amount_of_matched_text = yy_cp - yytext - 1;
  664.  
  665.         /* undo the effects of YY_DO_BEFORE_ACTION */
  666.         *yy_cp = yy_hold_char;
  667.  
  668.         /* note that here we test for yy_c_buf_p "<=" to the position
  669.          * of the first EOB in the buffer, since yy_c_buf_p will
  670.          * already have been incremented past the NUL character
  671.          * (since all states make transitions on EOB to the end-
  672.          * of-buffer state).  Contrast this with the test in yyinput().
  673.          */
  674.         if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  675.             /* this was really a NUL */
  676.             {
  677.             yy_state_type yy_next_state;
  678.  
  679.             yy_c_buf_p = yytext + yy_amount_of_matched_text;
  680.  
  681.             yy_current_state = yy_get_previous_state();
  682.  
  683.             /* okay, we're now positioned to make the
  684.              * NUL transition.  We couldn't have
  685.              * yy_get_previous_state() go ahead and do it
  686.              * for us because it doesn't know how to deal
  687.              * with the possibility of jamming (and we
  688.              * don't want to build jamming into it because
  689.              * then it will run more slowly)
  690.              */
  691.  
  692.             yy_next_state = yy_try_NUL_trans( yy_current_state );
  693.  
  694.             yy_bp = yytext + YY_MORE_ADJ;
  695.  
  696.             if ( yy_next_state )
  697.             {
  698.             /* consume the NUL */
  699.             yy_cp = ++yy_c_buf_p;
  700.             yy_current_state = yy_next_state;
  701.             goto yy_match;
  702.             }
  703.  
  704.             else
  705.             {
  706.                 yy_cp = yy_last_accepting_cpos;
  707.                 yy_current_state = yy_last_accepting_state;
  708.             goto yy_find_action;
  709.             }
  710.             }
  711.  
  712.         else switch ( yy_get_next_buffer() )
  713.             {
  714.             case EOB_ACT_END_OF_FILE:
  715.             {
  716.             yy_did_buffer_switch_on_eof = 0;
  717.  
  718.             if ( yywrap() )
  719.                 {
  720.                 /* note: because we've taken care in
  721.                  * yy_get_next_buffer() to have set up yytext,
  722.                  * we can now set up yy_c_buf_p so that if some
  723.                  * total hoser (like flex itself) wants
  724.                  * to call the scanner after we return the
  725.                  * YY_NULL, it'll still work - another YY_NULL
  726.                  * will get returned.
  727.                  */
  728.                 yy_c_buf_p = yytext + YY_MORE_ADJ;
  729.  
  730.                 yy_act = YY_STATE_EOF((yy_start - 1) / 2);
  731.                 goto do_action;
  732.                 }
  733.  
  734.             else
  735.                 {
  736.                 if ( ! yy_did_buffer_switch_on_eof )
  737.                 YY_NEW_FILE;
  738.                 }
  739.             }
  740.             break;
  741.  
  742.             case EOB_ACT_CONTINUE_SCAN:
  743.             yy_c_buf_p = yytext + yy_amount_of_matched_text;
  744.  
  745.             yy_current_state = yy_get_previous_state();
  746.  
  747.             yy_cp = yy_c_buf_p;
  748.             yy_bp = yytext + YY_MORE_ADJ;
  749.             goto yy_match;
  750.  
  751.             case EOB_ACT_LAST_MATCH:
  752.             yy_c_buf_p =
  753.                 &yy_current_buffer->yy_ch_buf[yy_n_chars];
  754.  
  755.             yy_current_state = yy_get_previous_state();
  756.  
  757.             yy_cp = yy_c_buf_p;
  758.             yy_bp = yytext + YY_MORE_ADJ;
  759.             goto yy_find_action;
  760.             }
  761.         break;
  762.         }
  763.  
  764.         default:
  765. #ifdef FLEX_DEBUG
  766.         printf( "action # %d\n", yy_act );
  767. #endif
  768.         YY_FATAL_ERROR(
  769.             "fatal flex scanner internal error--no action found" );
  770.         }
  771.     }
  772. }
  773.  
  774.  
  775. /* yy_get_next_buffer - try to read in a new buffer
  776.  *
  777.  * synopsis
  778.  *     int yy_get_next_buffer();
  779.  *
  780.  * returns a code representing an action
  781.  *     EOB_ACT_LAST_MATCH -
  782.  *     EOB_ACT_CONTINUE_SCAN - continue scanning from current position
  783.  *     EOB_ACT_END_OF_FILE - end of file
  784.  */
  785.  
  786. static int yy_get_next_buffer()
  787. {
  788.     register YY_CHAR *dest = yy_current_buffer->yy_ch_buf;
  789.     register YY_CHAR *source = yytext - 1; /* copy prev. char, too */
  790.     register int number_to_move, i;
  791.     int ret_val;
  792.  
  793.     if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
  794.     YY_FATAL_ERROR(
  795.         "fatal flex scanner internal error--end of buffer missed" );
  796.  
  797.     /* try to read more data */
  798.  
  799.     /* first move last chars to start of buffer */
  800.     number_to_move = yy_c_buf_p - yytext;
  801.  
  802.     for ( i = 0; i < number_to_move; ++i )
  803.     *(dest++) = *(source++);
  804.  
  805.     if ( yy_current_buffer->yy_eof_status != EOF_NOT_SEEN )
  806.     /* don't do the read, it's not guaranteed to return an EOF,
  807.      * just force an EOF
  808.      */
  809.     yy_n_chars = 0;
  810.  
  811.     else
  812.     {
  813.     int num_to_read = yy_current_buffer->yy_buf_size - number_to_move - 1;
  814.  
  815.     if ( num_to_read > YY_READ_BUF_SIZE )
  816.         num_to_read = YY_READ_BUF_SIZE;
  817.  
  818.     else if ( num_to_read <= 0 )
  819.         YY_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
  820.  
  821.     /* read in more data */
  822.     YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
  823.           yy_n_chars, num_to_read );
  824.     }
  825.  
  826.     if ( yy_n_chars == 0 )
  827.     {
  828.     if ( number_to_move - YY_MORE_ADJ == 1 )
  829.         {
  830.         ret_val = EOB_ACT_END_OF_FILE;
  831.         yy_current_buffer->yy_eof_status = EOF_DONE;
  832.         }
  833.  
  834.     else
  835.         {
  836.         ret_val = EOB_ACT_LAST_MATCH;
  837.         yy_current_buffer->yy_eof_status = EOF_PENDING;
  838.         }
  839.     }
  840.  
  841.     else
  842.     ret_val = EOB_ACT_CONTINUE_SCAN;
  843.  
  844.     yy_n_chars += number_to_move;
  845.     yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
  846.     yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
  847.  
  848.     /* yytext begins at the second character in yy_ch_buf; the first
  849.      * character is the one which preceded it before reading in the latest
  850.      * buffer; it needs to be kept around in case it's a newline, so
  851.      * yy_get_previous_state() will have with '^' rules active
  852.      */
  853.  
  854.     yytext = &yy_current_buffer->yy_ch_buf[1];
  855.  
  856.     return ( ret_val );
  857. }
  858.  
  859.  
  860. /* yy_get_previous_state - get the state just before the EOB char was reached
  861.  *
  862.  * synopsis
  863.  *     yy_state_type yy_get_previous_state();
  864.  */
  865.  
  866. static yy_state_type yy_get_previous_state()
  867. {
  868.     register yy_state_type yy_current_state;
  869.     register YY_CHAR *yy_cp;
  870.  
  871.     register YY_CHAR *yy_bp = yytext;
  872.  
  873.     yy_current_state = yy_start;
  874.     if ( yy_bp[-1] == '\n' )
  875.     ++yy_current_state;
  876.  
  877.     for ( yy_cp = yytext + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
  878.     {
  879.     register YY_CHAR yy_c = (*yy_cp ? yy_ec[*yy_cp] : 1);
  880.     if ( yy_accept[yy_current_state] )
  881.         {
  882.         yy_last_accepting_state = yy_current_state;
  883.         yy_last_accepting_cpos = yy_cp;
  884.         }
  885.     while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  886.         {
  887.         yy_current_state = yy_def[yy_current_state];
  888.         if ( yy_current_state >= 194 )
  889.         yy_c = yy_meta[yy_c];
  890.         }
  891.     yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  892.     }
  893.  
  894.     return ( yy_current_state );
  895. }
  896.  
  897.  
  898. /* yy_try_NUL_trans - try to make a transition on the NUL character
  899.  *
  900.  * synopsis
  901.  *     next_state = yy_try_NUL_trans( current_state );
  902.  */
  903.  
  904. static yy_state_type yy_try_NUL_trans( yy_current_state )
  905. register yy_state_type yy_current_state;
  906. {
  907.     register int yy_is_jam;
  908.     register YY_CHAR *yy_cp = yy_c_buf_p;
  909.  
  910.     register YY_CHAR yy_c = 1;
  911.     if ( yy_accept[yy_current_state] )
  912.     {
  913.     yy_last_accepting_state = yy_current_state;
  914.     yy_last_accepting_cpos = yy_cp;
  915.     }
  916.     while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  917.     {
  918.     yy_current_state = yy_def[yy_current_state];
  919.     if ( yy_current_state >= 194 )
  920.         yy_c = yy_meta[yy_c];
  921.     }
  922.     yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
  923.     yy_is_jam = (yy_current_state == 193);
  924.  
  925.     return ( yy_is_jam ? 0 : yy_current_state );
  926. }
  927.  
  928.  
  929. #if 0        /* not needed for NetHack */
  930.  
  931. static void yyunput( in_c, yy_bp )
  932. int in_c;        /* YY_CHAR c; */
  933. register YY_CHAR *yy_bp;
  934. {
  935.     register YY_CHAR *yy_cp = yy_c_buf_p;
  936.     YY_CHAR c = (YY_CHAR)in_c;
  937.  
  938.     /* undo effects of setting up yytext */
  939.     *yy_cp = yy_hold_char;
  940.  
  941.     if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  942.     { /* need to shift things up to make room */
  943.     register int number_to_move = yy_n_chars + 2; /* +2 for EOB chars */
  944.     register YY_CHAR *dest =
  945.         &yy_current_buffer->yy_ch_buf[yy_current_buffer->yy_buf_size + 2];
  946.     register YY_CHAR *source =
  947.         &yy_current_buffer->yy_ch_buf[number_to_move];
  948.  
  949.     while ( source > yy_current_buffer->yy_ch_buf )
  950.         *--dest = *--source;
  951.  
  952.     yy_cp += dest - source;
  953.     yy_bp += dest - source;
  954.     yy_n_chars = yy_current_buffer->yy_buf_size;
  955.  
  956.     if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
  957.         YY_FATAL_ERROR( "flex scanner push-back overflow" );
  958.     }
  959.  
  960.     if ( yy_cp > yy_bp && yy_cp[-1] == '\n' )
  961.     yy_cp[-2] = '\n';
  962.  
  963.     *--yy_cp = c;
  964.  
  965.     /* note: the formal parameter *must* be called "yy_bp" for this
  966.      *       macro to now work correctly
  967.      */
  968.     YY_DO_BEFORE_ACTION; /* set up yytext again */
  969. }
  970.  
  971.  
  972. static int yyinput()
  973. {
  974.     int c;
  975.     YY_CHAR *yy_cp = yy_c_buf_p;
  976.  
  977.     *yy_cp = yy_hold_char;
  978.  
  979.     if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
  980.     {
  981.     /* yy_c_buf_p now points to the character we want to return.
  982.      * If this occurs *before* the EOB characters, then it's a
  983.      * valid NUL; if not, then we've hit the end of the buffer.
  984.      */
  985.     if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
  986.         /* this was really a NUL */
  987.         *yy_c_buf_p = '\0';
  988.  
  989.     else
  990.         { /* need more input */
  991.         yytext = yy_c_buf_p;
  992.         ++yy_c_buf_p;
  993.  
  994.         switch ( yy_get_next_buffer() )
  995.         {
  996.         case EOB_ACT_END_OF_FILE:
  997.             {
  998.             if ( yywrap() )
  999.             {
  1000.             yy_c_buf_p = yytext + YY_MORE_ADJ;
  1001.             return ( EOF );
  1002.             }
  1003.  
  1004.             YY_NEW_FILE;
  1005.  
  1006.             return ( yyinput() );
  1007.             }
  1008.             break;
  1009.  
  1010.         case EOB_ACT_CONTINUE_SCAN:
  1011.             yy_c_buf_p = yytext + YY_MORE_ADJ;
  1012.             break;
  1013.  
  1014.         case EOB_ACT_LAST_MATCH:
  1015.             YY_FATAL_ERROR( "unexpected last match in yyinput()" );
  1016.         }
  1017.         }
  1018.     }
  1019.  
  1020.     c = *yy_c_buf_p;
  1021.     yy_hold_char = *++yy_c_buf_p;
  1022.  
  1023.     return ( c );
  1024. }
  1025.  
  1026. #endif    /* 0 */
  1027.  
  1028.  
  1029. void yyrestart( input_file )
  1030. FILE *input_file;
  1031. {
  1032.     yy_init_buffer( yy_current_buffer, input_file );
  1033.     yy_load_buffer_state();
  1034. }
  1035.  
  1036.  
  1037. void yy_switch_to_buffer( new_buffer )
  1038. YY_BUFFER_STATE new_buffer;
  1039. {
  1040.     if ( yy_current_buffer == new_buffer )
  1041.     return;
  1042.  
  1043.     if ( yy_current_buffer )
  1044.     {
  1045.     /* flush out information for old buffer */
  1046.     *yy_c_buf_p = yy_hold_char;
  1047.     yy_current_buffer->yy_buf_pos = yy_c_buf_p;
  1048.     yy_current_buffer->yy_n_chars = yy_n_chars;
  1049.     }
  1050.  
  1051.     yy_current_buffer = new_buffer;
  1052.     yy_load_buffer_state();
  1053.  
  1054.     /* we don't actually know whether we did this switch during
  1055.      * EOF (yywrap()) processing, but the only time this flag
  1056.      * is looked at is after yywrap() is called, so it's safe
  1057.      * to go ahead and always set it.
  1058.      */
  1059.     yy_did_buffer_switch_on_eof = 1;
  1060. }
  1061.  
  1062.  
  1063. void yy_load_buffer_state()
  1064. {
  1065.     yy_n_chars = yy_current_buffer->yy_n_chars;
  1066.     yytext = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
  1067.     yyin = yy_current_buffer->yy_input_file;
  1068.     yy_hold_char = *yy_c_buf_p;
  1069. }
  1070.  
  1071.  
  1072. YY_BUFFER_STATE yy_create_buffer( file, size )
  1073. FILE *file;
  1074. int size;
  1075. {
  1076.     YY_BUFFER_STATE b;
  1077.  
  1078.     b = (YY_BUFFER_STATE) alloc( sizeof( struct yy_buffer_state ) );
  1079.     b->yy_buf_size = size;
  1080.  
  1081.     /* yy_ch_buf has to be 2 characters longer than the size given because
  1082.      * we need to put in 2 end-of-buffer characters.
  1083.      */
  1084.     b->yy_ch_buf = (YY_CHAR *) alloc( (unsigned) (b->yy_buf_size + 2) );
  1085.     yy_init_buffer( b, file );
  1086.  
  1087.     return ( b );
  1088. }
  1089.  
  1090.  
  1091. void yy_delete_buffer( b )
  1092. YY_BUFFER_STATE b;
  1093. {
  1094.     if ( b == yy_current_buffer )
  1095.     yy_current_buffer = (YY_BUFFER_STATE) 0;
  1096.  
  1097.     free((genericptr_t)b->yy_ch_buf);
  1098.     free((genericptr_t)b);
  1099. }
  1100.  
  1101.  
  1102. void yy_init_buffer( b, file )
  1103. YY_BUFFER_STATE b;
  1104. FILE *file;
  1105. {
  1106.     b->yy_input_file = file;
  1107.  
  1108.     /* we put in the '\n' and start reading from [1] so that an
  1109.      * initial match-at-newline will be true.
  1110.      */
  1111.  
  1112.     b->yy_ch_buf[0] = '\n';
  1113.     b->yy_n_chars = 1;
  1114.  
  1115.     /* we always need two end-of-buffer characters.  The first causes
  1116.      * a transition to the end-of-buffer state.  The second causes
  1117.      * a jam in that state.
  1118.      */
  1119.     b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
  1120.     b->yy_ch_buf[2] = YY_END_OF_BUFFER_CHAR;
  1121.  
  1122.     b->yy_buf_pos = &b->yy_ch_buf[1];
  1123.  
  1124.     b->yy_eof_status = EOF_NOT_SEEN;
  1125. }
  1126.  
  1127.  
  1128. /* routine to switch to another input file; needed for flex */
  1129. void init_yyin( input_f )
  1130. FILE *input_f;
  1131. {
  1132. #if defined(FLEX_SCANNER) || defined(FLEXHACK_SCANNER)
  1133.     if (yyin)
  1134.         yyrestart(input_f);
  1135.     else
  1136. #endif
  1137.         yyin = input_f;
  1138. }
  1139. /* analogous routine (for completeness) */
  1140. void init_yyout( output_f )
  1141. FILE *output_f;
  1142. {
  1143.     yyout = output_f;
  1144. }
  1145.  
  1146.